package net.sf.brutil.v0.light;

import java.util.Collection;

public class ObjectUtil {

	  @SuppressWarnings("unchecked")
		public static boolean isObjectEmpty(Object o){
			if (o==null) return true;
			if ((o instanceof String)) return ((String)o).isEmpty();
			if ((o instanceof Collection)) return ((Collection<?>)o).isEmpty();
			
			return false;
		}
		

	    public static boolean isEmpty(String o){
	        if (o==null) return true;
	        return ((String)o).isEmpty();
	        
	    }

	    public static boolean isEmptyOrBlank(String o){
	        if (o==null) return true;
	        return ((String)o).trim().isEmpty();
	        
	    }

	    public static boolean isEmpty(Collection<?> o){
	        if (o==null) return true;
	        return ((Collection<?>)o).isEmpty();
	        
	    }
	    

		

		public static<E> boolean equals(E tipoGasto, E tipoGasto2) {
			if (tipoGasto==tipoGasto2) return true;
			if (tipoGasto==null && tipoGasto2!=null) return false;
			if (tipoGasto!=null && tipoGasto2==null) return false;
			return tipoGasto.equals(tipoGasto2);
		}
		

		public static String toStringOrNull(Object value) {
			if (value==null) return null;
			return value.toString();
		}
		public static String toStringOrBlank(Object value) {
	        if (value==null) return "";
	        return value.toString();
	    }
		

		

		public static <T extends Comparable<T>> int compareTwo(T name, T name2) {
			if (name==null && name2==null) return 0;
			if (name==null) return -1;
			if (name2==null) return 1;
			return name.compareTo(name2);
		}
		
		
		
	

}
